package com.example.othree.service;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public interface FileService {
    FilePageInfo getFileInfosByPage(int page, int pageSize) throws IOException;
    List<String> getFileNames() throws IOException;

    class FilePageInfo {
        private Integer totalPages;
        private Integer pageSize;
        private Integer currentPage;
        private Integer total;

        private ArrayList<FileInfo> fileInfos;

        public FilePageInfo(Integer totalPages, Integer pageSize, Integer currentPage, Integer total, ArrayList<FileInfo> fileInfos) {
            this.totalPages = totalPages;
            this.pageSize = pageSize;
            this.currentPage = currentPage;
            this.total = total;
            this.fileInfos = fileInfos;
        }

        public Integer getTotalPages() {
            return totalPages;
        }

        public Integer getPageSize() {
            return pageSize;
        }

        public Integer getCurrentPage() {
            return currentPage;
        }

        public Integer getTotal() {
            return total;
        }

        public ArrayList<FileInfo> getFileInfos() {
            return fileInfos;
        }
    }

    class FileInfo {
        private String fileName;
        private Date lastModified;
        private long sizeInBytes;

        public FileInfo(String fileName, long lastModifiedMillis, long sizeInBytes) {
            this.fileName = fileName;
            this.lastModified = new Date(lastModifiedMillis);;
            this.sizeInBytes = sizeInBytes;
        }

        public String getFileName() {
            return fileName;
        }

        public Date getLastModified() {
            return lastModified;
        }

        public long getSizeInBytes() {
            return sizeInBytes;
        }
    }
}
